-
-
Notifications
You must be signed in to change notification settings - Fork 117
Refactor HTMLReader to improve encoding detection logic and HTMLWriter to AutoClosable #1419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
miurahr
wants to merge
10
commits into
master
Choose a base branch
from
topic/miurahr/filters2/html/refactor-reader-creation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor HTMLReader to improve encoding detection logic and HTMLWriter to AutoClosable #1419
miurahr
wants to merge
10
commits into
master
from
topic/miurahr/filters2/html/refactor-reader-creation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as outdated.
This comment was marked as outdated.
- Separated BOM detection, content-based encoding detection, and charset parsing into distinct methods for clarity and reusability. - Replaced redundant code with a streamlined structure, enhancing maintainability and readability. Signed-off-by: Hiroshi Miura <miurahr@linux.com> (cherry picked from commit 28daf3c) Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Introduced AutoCloseable implementation to streamline resource handling and added @OverRide annotations for better code clarity. Refactored fields to final, ensuring immutability and improving thread safety, while simplifying the writer functionality. Signed-off-by: Hiroshi Miura <miurahr@linux.com>
22a0cd7
to
2694720
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Introduced AbstractHtmlReader as a base class for HTMLReader to simplify encoding and file handling. Moved encoding detection logic to HTMLUtils for reusability and better separation of concerns. This enhances code modularity and reduces duplication. Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Enhanced error messages for test assertions to improve clarity when tests fail. This includes specifying encoding expectations and pinpointing differences in file size or content during comparisons. Signed-off-by: Hiroshi Miura <miurahr@linux.com>
69fc264
to
389f0ec
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Replaced the hardcoded "UTF-8" encoding in test assertions with `Charset.defaultCharset()` to align with system default behavior. This ensures better platform compatibility and correct encoding detection verification. Signed-off-by: Hiroshi Miura <miurahr@linux.com>
389f0ec
to
ef0bb61
Compare
- Reformatted code for better readability, using consistent indentation and line wrapping. - Enhanced encoding detection by introducing fallback logic and replacing String-based default encoding with a Charset-based approach. - Added JetBrains annotations (@NotNull, @nullable) to improve clarity and null safety. Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
…ng assertion Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Added tests to verify correct encoding detection for files with UTF-8, UTF-16 BE/LE BOM, and files without BOM. Introduced new test files to support encoding validation. Improved comments in existing tests for better readability. Signed-off-by: Hiroshi Miura <miurahr@linux.com>
❌ Quality checks failed. Please look a Gradle Scan page for details: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the HTMLReader class to improve readability, modularity, and make encoding detection more robust. Key improvements include replacing manual encoding detection with helper methods and migrating from String to the Charset type for encoding handling.
Pull request type
Which ticket is resolved?
There is no issue to point
What does this PR change?
Other information